package com.hebo.testdemo.controller;


import com.hebo.testdemo.model.TUser;
import com.hebo.testdemo.service.ITUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;


/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author test
 * @since 2021-08-05
 */
@Controller
@RequestMapping("/user")
public class TUserController {
    @Autowired
    private ITUserService itUserService;

    @PostMapping("/login")
    public String login(TUser tUser, HttpSession session) {
        TUser login = itUserService.login(tUser);
        if (login != null) {
            session.setAttribute("user",login);
            return "redirect:/files/findAll";
        }else {
            return "redirect:/index";
        }
    }

}
